package testes.vSys.dao;

import java.util.Collection;
import java.util.Date;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;

import testes.vSys.bean.EventType;
import testes.vSys.bean.Moviment;
import testes.vSys.bean.Vehicle;

public class _stub_MovimentDao implements IMovimentDao{

	
	private LinkedHashMap<Integer, EventType> eventType;
	private LinkedHashMap<Integer, Moviment> moviments;
	
	private int currentId = 4;
	
	public _stub_MovimentDao() {
		eventType = new LinkedHashMap<Integer, EventType>();
		moviments = new LinkedHashMap<Integer, Moviment>();
		
		eventType.put(1, new EventType(1,"tipo 1"));
		eventType.put(2, new EventType(2,"tipo 2"));
		eventType.put(3, new EventType(3,"tipo 3"));
		eventType.put(4, new EventType(4,"tipo 4"));
		
		EventType event = new EventType(1);
		event.setEventType("C");

		Vehicle vehicle = new Vehicle();
		Moviment moviment = new Moviment();
		moviment.setDate( new Date());
		moviment.setKilometers(100);
		moviment.setEventType(null);
		moviment.setValue(2000);
		moviment.setEventType(event);
		moviment.setVehicle(vehicle);
		moviments.put(1,moviment);
		
		vehicle.setPlate("CFD2141");
		
		event = new EventType(2);
		event.setEventType("V");
		
		moviment = new Moviment();
		moviment.setDate(new Date());
		moviment.setKilometers(800);
		moviment.setEventType(null);
		moviment.setValue(1500);
		moviment.setEventType(event);
		moviment.setVehicle(vehicle);
		moviments.put(2,moviment);
		
		vehicle = new Vehicle();
		vehicle.setPlate("CFD2141");
		
		event = new EventType(3);
		event.setEventType("T");
		
		moviment = new Moviment();
		moviment.setDate(new Date());
		moviment.setKilometers(1800);
		moviment.setEventType(null);
		moviment.setValue(500);
		moviment.setEventType(event);
		moviment.setVehicle(vehicle);
		moviments.put(3,moviment);
		
		vehicle = new Vehicle();
		vehicle.setPlate("CFD2141");
		
		event = new EventType(1);
		event.setEventType("C");
		
		moviment = new Moviment();
		moviment.setDate(new Date());
		moviment.setKilometers(7800);
		moviment.setEventType(null);
		moviment.setValue(15000);
		moviment.setEventType(event);
		moviment.setVehicle(vehicle);
		moviments.put(3,moviment);
		
		vehicle = new Vehicle();
		vehicle.setPlate("CFD2141");
		
		event = new EventType(1);
		event.setEventType("C");
		
		moviment = new Moviment();
		moviment.setDate(new Date());
		moviment.setKilometers(2100);
		moviment.setEventType(null);
		moviment.setValue(5500);
		moviment.setEventType(event);
		moviment.setVehicle(vehicle);
		moviments.put(4,moviment);
	}

	public EventType getEventType(int id) {
		// TODO Auto-generated method stub
		return (new EventType(5, "tipo teste"));
	}

	public Moviment createMoviment(Moviment moviment) {
		currentId++;
		moviment.setId(currentId);
		return moviments.put(currentId, moviment);
	}

	public Collection<Moviment> getMovimentBetween(Date start, Date end) {
		// TODO Auto-generated method stub
		return null;
	}

	public Collection<Moviment> getMovimentByVehicle(Vehicle vehicle) {
		//Collections moviments = new Collections();
		
		LinkedHashSet<Moviment> moviments_vehicle = new LinkedHashSet();
		Moviment m;
		
		Iterator i = moviments.values().iterator();
		
		while(i.hasNext()){
			m = ((Moviment)i.next());
			
			if( m.getVehicle().getPlate()==vehicle.getPlate()){
				moviments_vehicle.add(m);
			}
		}
		
		
		return moviments_vehicle;
	}	

	public Collection<EventType> getAvaiableEvents() {
		// TODO Auto-generated method stub
		return eventType.values();
	}

	public boolean removeMoviment(int movimentId) {
		// TODO Auto-generated method stub
		return false;
	}

	public Collection<Moviment> getMoviment(Moviment moviment) {
		// TODO Auto-generated method stub
		return null;
	}

	public EventType getEvent(int id) {
		// TODO Auto-generated method stub
		return null;
	}

	public boolean updateMoviment(Moviment moviment) {
		// TODO Auto-generated method stub
		return false;
	}



}
